package com.tg.app.activity.account;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.widget.Switch;

import com.appbase.custom.constant.CommonConstants;
import com.base.BaseActivity;
import com.tange.base.toolkit.PreferenceUtil;
import com.tg.app.R;
import com.tg.appcommon.android.TGApplicationBase;
import com.tg.data.media.MediaDecoderConfig;
import com.tg.loginex.helper.LoginHelper;

public class AccountSettingsActivity extends BaseActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);//remove title bar  即隐藏标题栏
        setContentView(R.layout.activity_account_settings);
        hideActionBar();
        initView();
    }

    @Override
    public boolean shouldSetStatusBarColor() {
        return true;
    }

    @Override
    protected void initView() {
        View accountView = findViewById(R.id.account_user);
        String lastChannel = LoginHelper.getLastLoginChannel();
        if (CommonConstants.LOGIN_CHANNEL_FACEBOOK.equals(lastChannel)) {
            accountView.setVisibility(View.GONE);
        } else if (CommonConstants.LOGIN_CHANNEL_GOOGLE.equals(lastChannel)) {
            accountView.setVisibility(View.GONE);
        } else if (CommonConstants.LOGIN_CHANNEL_LINE.equals(lastChannel)) {
            accountView.setVisibility(View.GONE);
        }
        findViewById(R.id.account_user).setOnClickListener(v -> {
//            Intent intent = new Intent(getBaseContext(), AccountAndSafeActivity.class);
//            startActivity(intent);
        });
        findViewById(R.id.account_toolbox).setOnClickListener(v -> {
            Intent toolIntent = new Intent(getBaseContext(), ToolBoxActivity.class);
            startActivity(toolIntent);
        });
        findViewById(R.id.back_toolbar).setOnClickListener(v -> finish());
        boolean supportAiSound = PreferenceUtil.getBoolean(TGApplicationBase.getApplicationContext(), CommonConstants.PRE_SETTINGS_AI_SOUND,false);
        Switch sw = findViewById(R.id.sw_settings_ai_sound);
        sw.setChecked(supportAiSound);
        sw.setOnClickListener(v -> {
            PreferenceUtil.setBoolean(TGApplicationBase.getApplicationContext(), CommonConstants.PRE_SETTINGS_AI_SOUND, sw.isChecked());
            MediaDecoderConfig.getInstance().setUseAudioAIDecoder(sw.isChecked());
        });
    }
}